package xyz.thoughtset.viewer.executor.core.factory;

import lombok.Getter;
import xyz.thoughtset.viewer.executor.core.base.AbstractExecutor;
import xyz.thoughtset.viewer.executor.core.base.DataContext;

import java.util.LinkedHashSet;
import java.util.Objects;
import java.util.concurrent.ConcurrentHashMap;


public class ExecutorRegistry {
    private static AbstractExecutor DEFAULT = null;
    private static final ConcurrentHashMap<String, AbstractExecutor> Executor_Map = new ConcurrentHashMap<>();
//    @Getter
//    private static final LinkedHashSet<String> Executor_Keys = new LinkedHashSet<>();

    public static void register(AbstractExecutor executor) {
        if (DEFAULT==null) DEFAULT = executor;
        Executor_Map.put(executor.getSupportType(), executor);
//        Executor_Keys.add(executor.getSupportType());
    }

    public static AbstractExecutor findExecutor(String supportType){
        AbstractExecutor executor = Executor_Map.get(supportType);
        if (executor == null) {
            return DEFAULT;
        }
        return executor;
    }

}
